function get_repose()
{
    expect -c "
    spawn $*
    expect {
        \"*yes/no*\" {send \"yes\n\"}
        eof
    }
    catch wait result;
    exit [lindex \$result 3]
    "
}

function get_latest()
{
    # release iso path
    release_path=$1
    key_file=$2
    echo $(get_repose ssh -i ${key_file} root@121.36.84.172 ls -lt ${release_path} | grep -v test | grep -v total | head -n 1 | awk '{print $9}')
}

function get_mount_iso()
{
    # path of iso should be mounted on
    iso_mount_dir=$1
    echo `mount | grep ${iso_mount_dir} | awk '{print $1}'`
}

latest=$(get_latest "/repo/openeuler/dailybuild/openEuler-21.09" "~/super_publish_rsa")
echo $latest
exit 0
res=$(get_mount_iso "$latest/OS/aarch64")
if [[ $res ]];then
    echo $res
else
    echo "Not find"
fi
